﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Fluent="clr-namespace:Fluent" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/Fluent;component\Themes\Office2010\Controls\MenuSeparator.xaml"/>
  </ResourceDictionary.MergedDictionaries>
  <Fluent:ObjectToImageConverter x:Key="StringToImageConvert"/>
  <Style x:Key="RibbonSplitButtonStyle" TargetType="{x:Type Fluent:SplitButton}">
    <Setter Property="Template" Value="{DynamicResource RibbonSplitButtonControlTemplate}"/>
    <Setter Property="Height" Value="66"/>
    <Setter Property="Width" Value="Auto"/>
    <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}"/>
    <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}"/>
    <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}"/>
    <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Style.Triggers>
      <Trigger Property="Size" Value="Large">
        <Setter Property="Height" Value="66"/>
      </Trigger>
      <Trigger Property="Size" Value="Middle">
        <Setter Property="Height" Value="22"/>
      </Trigger>
      <Trigger Property="Size" Value="Small">
        <Setter Property="Height" Value="22"/>
        <Setter Property="Width" Value="34"/>
      </Trigger>
    </Style.Triggers>
  </Style>
    
  <ControlTemplate x:Key="RibbonSplitButtonControlTemplate" TargetType="{x:Type Fluent:SplitButton}">
    <ControlTemplate.Resources>
      <Style BasedOn="{StaticResource MenuSeparatorStyle}" TargetType="{x:Type Separator}"/>
    </ControlTemplate.Resources>
    <Grid>
  <Border x:Name="PART_ButtonBorder" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}" BorderBrush="{DynamicResource TransparentBrush}" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Stretch" SnapsToDevicePixels="True" ToolTip="{TemplateBinding DropDownToolTip}">
      <Border x:Name="border1" Height="Auto" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}">
        <Grid x:Name="grid" Height="Auto">
          <Rectangle x:Name="rectangle" StrokeThickness="0" Visibility="Collapsed">
            <Rectangle.Fill>
              <RadialGradientBrush Center="0.503,1" GradientOrigin="0.503,1" RadiusY="0.202">
                <GradientStop Color="#7FFFFFFF" Offset="0"/>
                <GradientStop Offset="1"/>
              </RadialGradientBrush>
            </Rectangle.Fill>
          </Rectangle>      		
          <Border x:Name="downRect" VerticalAlignment="Bottom" Height="28" Background="{DynamicResource TransparentBrush}" BorderThickness="0,1,0,0" Margin="-1,0"/>
          <Border x:Name="downRect_Copy" VerticalAlignment="Bottom" Height="27" Background="{DynamicResource TransparentBrush}" BorderThickness="1" Margin="-1,1,-1,0" IsHitTestVisible="False"/>
          <StackPanel x:Name="stackPanel" Width="Auto" Orientation="Vertical" d:LayoutOverrides="Width, Height" IsHitTestVisible="False" Margin="0">
            <ContentPresenter x:Name="iconImage" HorizontalAlignment="Center" Height="32" VerticalAlignment="Center" Content="{x:Null}" Width="32" Margin="3,2" SnapsToDevicePixels="True" IsHitTestVisible="false" Visibility="Hidden" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
            <Fluent:TwoLineLabel x:Name="controlLabel" Text="{TemplateBinding Header}" Style="{DynamicResource TwoLineLabelStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,-2,2,2" HasGlyph="{TemplateBinding HasTriangle}"/>
          </StackPanel>
          <Fluent:ToggleButton x:Name="PART_Button" Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding CommandParameter}" CommandTarget="{TemplateBinding CommandTarget}" Margin="-2,-2,-2,26" Height="Auto" Width="Auto" Style="{DynamicResource InnerButtonStyle}" LargeIcon="{Binding LargeIcon, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToImageConvert}}" Icon="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToImageConvert}}" IsEnabled="{TemplateBinding IsButtonEnabled}" Header="{TemplateBinding Header}" ToolTip="{TemplateBinding ToolTip}" IsChecked="{Binding IsChecked, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsDefinitive="{TemplateBinding IsDefinitive}" CanAddToQuickAccessToolBar="{TemplateBinding CanAddButtonToQuickAccessToolBar}"/>
        </Grid>
      </Border>
    </Border>
  <Popup 
            x:Name="PART_Popup"
            Placement="Bottom"
            IsOpen="{TemplateBinding IsDropDownOpen}"
            AllowsTransparency="True" 
            Focusable="False"
            PopupAnimation="Fade" Margin="0,0,-4,0" VerticalAlignment="Top" Grid.ColumnSpan="2">
            <Grid 
              Name="DropDown"
              SnapsToDevicePixels="True" Margin="0" VerticalAlignment="Top">
              <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="10"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="10"/>
      </Grid.ColumnDefinitions>
      <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="4" Height="4" Grid.Row="1" Grid.Column="1" StrokeThickness="0" Margin="-1,-1,0,0">
        <Rectangle.Fill>
          <RadialGradientBrush RadiusX="0.984" Center="0.017,0.002" GradientOrigin="0.017,0.002" RadiusY="1">
            <GradientStop Color="#3F000000" Offset="0"/>
            <GradientStop Color="#00000000" Offset="1"/>
          </RadialGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle StrokeThickness="0" HorizontalAlignment="Left" Margin="-1,3,0,0" VerticalAlignment="Top" Width="4" Height="4" Grid.Column="1" Grid.Row="0">
        <Rectangle.Fill>
          <RadialGradientBrush Center="0.032,1.01" GradientOrigin="0.032,1.01" RadiusX="0.984" RadiusY="1">
            <GradientStop Color="#3F000000" Offset="0"/>
            <GradientStop Color="#00000000" Offset="1"/>
          </RadialGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle StrokeThickness="0" HorizontalAlignment="Left" Margin="3,-1,0,0" VerticalAlignment="Top" Width="4" Height="4" Grid.Column="0" Grid.Row="1">
        <Rectangle.Fill>
          <RadialGradientBrush Center="0.996,0.027" GradientOrigin="0.996,0.027" RadiusX="0.984" RadiusY="1">
            <GradientStop Color="#3F000000" Offset="0"/>
            <GradientStop Color="#00000000" Offset="1"/>
          </RadialGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle StrokeThickness="0" HorizontalAlignment="Stretch" Margin="7,-1,1,0" VerticalAlignment="Top" Width="Auto" Height="4" Grid.Column="0" Grid.Row="1">
        <Rectangle.Fill>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
            <GradientStop Color="#3F000000" Offset="0"/>
            <GradientStop Color="#00000000" Offset="1"/>
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Rectangle StrokeThickness="0" HorizontalAlignment="Left" Margin="-1,7,0,1" VerticalAlignment="Stretch" Width="4" Height="Auto" Grid.Column="1" Grid.Row="0">
        <Rectangle.Fill>
          <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5" MappingMode="RelativeToBoundingBox">
            <GradientStop Color="#3F000000" Offset="0"/>
            <GradientStop Color="#00000000" Offset="1"/>
          </LinearGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
    <Border x:Name="PART_DropDownBorder" MinWidth="{TemplateBinding ActualWidth}" SnapsToDevicePixels="True" Background="{DynamicResource ContextMenuBarBackgroundBrush}" BorderBrush="{DynamicResource ContextMenuBarBorderBrush}" BorderThickness="1" CornerRadius="1" Grid.ColumnSpan="1" d:LayoutOverrides="Width, Height" HorizontalAlignment="Stretch" VerticalAlignment="Top">
        <Grid Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Top">
          <Border VerticalAlignment="Top" Width="Auto" Height="Auto" BorderBrush="{DynamicResource ContextMenuBarBackgroundBrush}" BorderThickness="1" CornerRadius="1"/>
          <Grid Margin="1" HorizontalAlignment="Stretch" VerticalAlignment="Top">
            <Grid.RowDefinitions>
              <RowDefinition Height="*"/>
              <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Rectangle Fill="{x:Null}" Stretch="Fill" Stroke="#FFE2E4E7" HorizontalAlignment="Left" Margin="24,0,0,0" Width="1" Height="Auto" Grid.RowSpan="2" Visibility="Visible" VerticalAlignment="Stretch"/>
            <ScrollViewer x:Name="PART_ScrollViewer" Style="{DynamicResource MenuScrollViewer}" Margin="1" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
                <Fluent:MenuPanel x:Name="PART_MenuPanel" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
              </ScrollViewer>
            <Border x:Name="resizeBorder" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="11" BorderBrush="{DynamicResource ContextMenuBarResizeBorderBrush}" BorderThickness="0,1,0,0" Grid.Row="1" CornerRadius="0,0,1,1" Background="{DynamicResource ContextMenuBarResizeBackgoundBrush}">
              <Grid>
                <Thumb x:Name="PART_ResizeVerticalThumb" HorizontalAlignment="Stretch" Margin="0,0,0,-90" Width="Auto" Height="10" VerticalAlignment="Top" Cursor="SizeNS" Template="{DynamicResource ResizeVerticalThumbControlTemplate}"/>
                <Thumb x:Name="PART_ResizeBothThumb" HorizontalAlignment="Right" Margin="0,0,0,-90" Width="10" Height="10" VerticalAlignment="Top" Cursor="SizeNWSE" Template="{DynamicResource ResizeBothThumbControlTemplate}"/>
              </Grid>
            </Border>
          </Grid>
        </Grid>
      </Border>              
            </Grid>
          </Popup>
      </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="ResizeMode" Value="None">
        <Setter Property="Visibility" TargetName="resizeBorder" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="ResizeMode" Value="Both">
        <Setter Property="Visibility" TargetName="PART_ResizeVerticalThumb" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_ResizeBothThumb" Value="Visible"/>
        <Setter Property="Visibility" TargetName="resizeBorder" Value="Visible"/>
      </Trigger>
      <Trigger Property="ResizeMode" Value="Vertical">
        <Setter Property="Visibility" TargetName="PART_ResizeBothThumb" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_ResizeVerticalThumb" Value="Visible"/>
        <Setter Property="Visibility" TargetName="resizeBorder" Value="Visible"/>
      </Trigger>
      <Trigger Property="IsChecked" Value="True">
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
        <Setter Property="Background" TargetName="PART_ButtonBorder" Value="{DynamicResource ButtonPressedInnerBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="downRect" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
      </Trigger>
      <Trigger Property="Size" Value="Small">
        <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal"/>
<!--        <Setter Property="Content" TargetName="iconImage" Value="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToImageConvert}}"/>-->
        <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
        <Setter Property="Text" TargetName="controlLabel" Value=""/>
        <Setter Property="Width" TargetName="iconImage" Value="16"/>
        <Setter Property="Height" TargetName="iconImage" Value="16"/>
        <Setter Property="Margin" TargetName="iconImage" Value="1,0,0,0"/>
        <Setter Property="Margin" TargetName="controlLabel" Value="3,-1,0,1"/>
        <Setter Property="Margin" TargetName="PART_Button" Value="-2,-2,10,-2"/>
        <Setter Property="VerticalAlignment" TargetName="downRect" Value="Stretch"/>
        <Setter Property="HorizontalAlignment" TargetName="downRect" Value="Right"/>
        <Setter Property="Height" TargetName="downRect" Value="Auto"/>
        <Setter Property="Margin" TargetName="downRect" Value="-1,-2,-1,-1"/>
        <Setter Property="HorizontalAlignment" TargetName="controlLabel" Value="Right"/>
        <Setter Property="BorderThickness" TargetName="downRect" Value="1,0,0,0"/>
        <Setter Property="Margin" TargetName="downRect_Copy" Value="-1"/>
        <Setter Property="VerticalAlignment" TargetName="downRect_Copy" Value="Stretch"/>
        <Setter Property="HorizontalAlignment" TargetName="downRect_Copy" Value="Right"/>
        <Setter Property="Height" TargetName="downRect_Copy" Value="Auto"/>
        <Setter Property="Width" TargetName="downRect" Value="12"/>
        <Setter Property="Width" TargetName="downRect_Copy" Value="11"/>
        <Setter Property="Width" TargetName="controlLabel" Value="12"/>
        <Setter Property="Size" TargetName="PART_Button" Value="Small"/>
        <Setter Property="VerticalAlignment" TargetName="controlLabel" Value="Center"/>
      </Trigger>
      <Trigger Property="Size" Value="Middle">
        <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal"/>
<!--        <Setter Property="Content" TargetName="iconImage" Value="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToImageConvert}}"/>-->
        <Setter Property="VerticalAlignment" TargetName="iconImage" Value="Center"/>
        <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
        <Setter Property="Margin" TargetName="controlLabel" Value="3,-1,-2,1"/>
        <Setter Property="VerticalAlignment" TargetName="PART_ButtonBorder" Value="Stretch"/>
        <Setter Property="Width" TargetName="iconImage" Value="16"/>
        <Setter Property="Height" TargetName="iconImage" Value="16"/>
        <Setter Property="Margin" TargetName="iconImage" Value="1,0,2,0"/>
        <Setter Property="Margin" TargetName="PART_Button" Value="-2,-2,10,-2"/>
        <Setter Property="HorizontalAlignment" TargetName="downRect" Value="Right"/>
        <Setter Property="VerticalAlignment" TargetName="downRect" Value="Stretch"/>
        <Setter Property="Height" TargetName="downRect" Value="Auto"/>
        <Setter Property="Style" TargetName="PART_Button" Value="{DynamicResource InnerButtonStyle}"/>
        <Setter Property="Margin" TargetName="downRect" Value="-1,-2,-1,-1"/>
        <Setter Property="HorizontalAlignment" TargetName="downRect_Copy" Value="Right"/>
        <Setter Property="VerticalAlignment" TargetName="downRect_Copy" Value="Stretch"/>
        <Setter Property="Height" TargetName="downRect_Copy" Value="Auto"/>
        <Setter Property="Margin" TargetName="downRect_Copy" Value="-1"/>
        <Setter Property="Width" TargetName="downRect" Value="12"/>
        <Setter Property="Width" TargetName="downRect_Copy" Value="11"/>
        <Setter Property="Size" TargetName="PART_Button" Value="Middle"/>
        <Setter Property="BorderThickness" TargetName="downRect" Value="1,0,0,0"/>
        <Setter Property="Text" TargetName="controlLabel" Value=""/>
        <Setter Property="HorizontalAlignment" TargetName="stackPanel" Value="Right"/>
        <Setter Property="Width" TargetName="stackPanel" Value="Auto"/>
        <Setter Property="Width" TargetName="controlLabel" Value="12"/>
        <Setter Property="HorizontalAlignment" TargetName="grid" Value="Stretch"/>
        <Setter Property="VerticalAlignment" TargetName="controlLabel" Value="Center"/>
        <Setter Property="HorizontalAlignment" TargetName="controlLabel" Value="Right"/>
      </Trigger>
      <Trigger Property="IsDropDownOpen" Value="True">
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="downRect" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
      </Trigger>
      <Trigger Property="IsButtonEnabled" Value="False">
        <Setter Property="Opacity" TargetName="iconImage" Value="0.5"/>
        <Setter Property="Effect" TargetName="iconImage">
          <Setter.Value>
            <Fluent:GrayscaleEffect/>
          </Setter.Value>
        </Setter>
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True"/>
          <Condition Property="IsDropDownOpen" Value="False"/>
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>        
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="downRect" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" SourceName="downRect" Value="True"/>
          <Condition Property="IsDropDownOpen" Value="False"/>
        </MultiTrigger.Conditions>
        <Setter Property="Background" TargetName="downRect" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
        <Setter Property="BorderBrush" TargetName="downRect" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="downRect_Copy" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
        <Setter Property="Background" TargetName="downRect_Copy" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
      </MultiTrigger>
      <!--<MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsFocused" Value="True"/>
          <Condition Property="IsDropDownOpen" Value="False"/>
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
        <Setter Property="Background" TargetName="downRect" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>        
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="downRect" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
      </MultiTrigger>-->
    </ControlTemplate.Triggers>
  </ControlTemplate>

  
  <!--Inner Button Style (Button in SplitButton)-->  
  <Style x:Key="InnerButtonStyle" TargetType="{x:Type Fluent:ToggleButton}">
    <Setter Property="Template" Value="{DynamicResource InnerButtonControlTemplate}"/>
    <Setter Property="VerticalAlignment" Value="Stretch"/>
    <Setter Property="HorizontalAlignment" Value="Stretch"/>
  <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}"/>
  </Style>
  
  <ControlTemplate x:Key="InnerButtonControlTemplate" TargetType="{x:Type Fluent:ToggleButton}">
    <Border x:Name="border" BorderThickness="1" CornerRadius="2,2,0,0" Background="{DynamicResource TransparentBrush}" BorderBrush="{DynamicResource TransparentBrush}" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SnapsToDevicePixels="False">
      <Border x:Name="border1" Height="Auto" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1" CornerRadius="2,2,0,0" Background="{DynamicResource TransparentBrush}">
        <Grid Height="Auto">
          <Rectangle x:Name="rectangle" StrokeThickness="0" Visibility="Collapsed">
            <Rectangle.Fill>
              <RadialGradientBrush Center="0.503,1" GradientOrigin="0.503,1" RadiusY="0.202">
                <GradientStop Color="#7FFFFFFF" Offset="0"/>
                <GradientStop Offset="1"/>
              </RadialGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <StackPanel x:Name="stackPanel" Width="Auto" Orientation="Vertical" d:LayoutOverrides="Width, Height" HorizontalAlignment="Stretch" SnapsToDevicePixels="True">
            <ContentPresenter x:Name="iconImage" HorizontalAlignment="Center" Height="32" VerticalAlignment="Center" Content="{TemplateBinding LargeIcon}" Width="32" Margin="0,2,0,1" RenderOptions.BitmapScalingMode="NearestNeighbor" SnapsToDevicePixels="True"/>
            <Fluent:TwoLineLabel x:Name="controlLabel" Text="{TemplateBinding Header}" Style="{DynamicResource TwoLineLabelStyle}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="2,-1,2,2" Visibility="Collapsed"/>
          </StackPanel>
        </Grid>
      </Border>
    </Border>
    <ControlTemplate.Triggers>			
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
        <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonPressedOuterBackgroundBrush}"/>
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBorderBrush}"/>
      </Trigger>			
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True"/>
          <Condition Property="IsPressed" Value="False"/>
          <Condition Property="IsEnabled" Value="True"/>
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
        <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
        <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsKeyboardFocusWithin" Value="True"/>
          <Condition Property="IsPressed" Value="False"/>
          <Condition Property="IsEnabled" Value="True"/>
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
        <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
        <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
      </MultiTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" TargetName="iconImage" Value="0.5"/>
        <Setter Property="Opacity" TargetName="controlLabel" Value="0.5"/>
        <Setter Property="Effect" TargetName="iconImage">
          <Setter.Value>
            <Fluent:GrayscaleEffect/>
          </Setter.Value>
        </Setter>
      </Trigger>
    <Trigger Property="Size" Value="Small">
        <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal"/>
        <Setter Property="Visibility" TargetName="controlLabel" Value="Collapsed"/>
        <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
        <Setter Property="Width" TargetName="iconImage" Value="16"/>
        <Setter Property="Height" TargetName="iconImage" Value="16"/>
        <Setter Property="Margin" TargetName="iconImage" Value="1,0,2,0"/>				
        <Setter Property="Content" TargetName="iconImage" Value="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="CornerRadius" TargetName="border" Value="2,0,0,2"/>
        <Setter Property="CornerRadius" TargetName="border1" Value="2,0,0,2"/>
        <Setter Property="Margin" TargetName="controlLabel" Value="2,-1,2,1"/>				
      </Trigger>
      <Trigger Property="Size" Value="Middle">
        <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal"/>
        <Setter Property="Width" TargetName="stackPanel" Value="Auto"/>
        <Setter Property="VerticalAlignment" TargetName="iconImage" Value="Center"/>
        <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
        <Setter Property="Margin" TargetName="controlLabel" Value="2,-1,-1,1"/>
        <Setter Property="VerticalAlignment" TargetName="border" Value="Stretch"/>
        <Setter Property="Width" TargetName="iconImage" Value="16"/>
        <Setter Property="Height" TargetName="iconImage" Value="16"/>
        <Setter Property="Margin" TargetName="iconImage" Value="1,0,2,0"/>			
        <Setter Property="Content" TargetName="iconImage" Value="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="CornerRadius" TargetName="border1" Value="2,0,0,2"/>
        <Setter Property="CornerRadius" TargetName="border" Value="2,0,0,2"/>
        <Setter Property="Visibility" TargetName="controlLabel" Value="Visible"/>
        <Setter Property="VerticalAlignment" TargetName="controlLabel" Value="Center"/>				
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
</ResourceDictionary>